fi = open("sensor.txt","r")
fo =open("earpa001.txt","w")
# read() 调用read()方法可以一次读取文件的全部内容
# readlines()可以按照⾏的⽅式把整个⽂件中的内容进⾏⼀次性读取，
# 并且返回的是⼀个列表，其中每⼀⾏的数据为⼀个元素。
# readline()⼀次读取⼀⾏内容。
lines = fi.readlines()
for line in lines:
    dateTime,sensor_num,floor,regional = line.split(",")
    if "earpa001" in line:
        fo.write('{},{},{},{}\n'.format(dateTime,sensor_num,floor,regional))
fi.close()
fo.close()
